package view
{
	import com.liu.load.LoadInfo;
	import com.liu.load.LoadManager;
	
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filesystem.File;
	import flash.net.URLRequest;
	
	import models.ModelLocator;
	
	public class BitmapSprite extends Sprite
	{
		public var content:Sprite;
		public var data:Object;
		private var model:ModelLocator = ModelLocator.getInstance();
		public function BitmapSprite()
		{
			content = new Sprite;
			this.addChild(content);
		}
		public function setData(obj:Object):void{
			this.data = obj;
			this.x = obj.x;
			this.y = obj.y;
			
			var loadinfo:LoadInfo;
			/*if(obj.ishot){
				loadinfo = new LoadInfo(model.hoticon + "/" +obj.url,LoadInfo.BITMAP,onComplete);
			}else{
				loadinfo = new LoadInfo(model.serverUrl + obj.url,LoadInfo.BITMAP,onComplete);
			}*/
			//loadinfo = new LoadInfo(model.serverUrl + obj.url,LoadInfo.BITMAP,onComplete);
			var str:String = data.url;
			if(str.indexOf("http://") != -1){
				loadinfo = new LoadInfo(obj.url,LoadInfo.BITMAP,onComplete);
			}else{
				loadinfo = new LoadInfo("http://www.ugan.cn/flash/bin-debug/" + obj.url,LoadInfo.BITMAP,onComplete);
			}
			
			
			
			LoadManager.getInstance().addSingleLoad(loadinfo);
		}
		public function onComplete(bitmap:Bitmap):void{
			bitmap.scaleX = bitmap.scaleY = data.scale * data.baseScale;
			bitmap.smoothing = true;
			content.addChild(bitmap);
			bitmap.x = -bitmap.width/2;
			bitmap.y = -bitmap.height/2;
			content.rotation = data.rotation;
			this.dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}